<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>

</div><!-- end .row -->
</div>
</div><!-- end #body -->


</body>

<button class="mdui-fab mdui-fab-fixed mdui-ripple top mdui-color-theme mdui-shadow-5" style="display:none"
        id="gotop">
    <i class="mdui-icon material-icons ">arrow_upward</i>
</button>

<script>

    function goTop() {
        //速度
        var speed = 100;
        //开启定时器
        var timer = setInterval(function() {
            //获取滚动条的高度
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            //设置滚动的高度
            document.documentElement.scrollTop = document.body.scrollTop = (scrollTop - speed);
            //清除定时器
            speed += 30;
            if (scrollTop <= 0) {
                clearInterval(timer);
            }
        }, 30)
    }

    document.getElementById('gotop').onclick = function() {
        goTop(); //调用函数
    }

    document.onscroll = function() {
        var top = document.getElementById('gotop');
        if (document.documentElement.scrollTop >= 250)
            top.style = "";
        else
            top.style = "display:none;";
    }


</script>

<!--<div style="text-align: center;margin-top: 100px;">-->
<footer style="text-align: center;margin-top: 100px;margin-bottom: 60px" class="mdui-card-content blog_footer">
	<p>
		<?php
const PATH = 'min.txt';
$min_after = 0;
$min_five_minutes = 0;
$total = 0;

if(file_exists(PATH)){
	$line = file(PATH)[1];
	$time = explode(',',$line);
	if(count($time) == 2){
		$time = date('d',$time[1]);
		$currenrTime = date('d',time());
		if($time != $currenrTime)
			unlink(PATH);
	}
}

$f = fopen(PATH,"a");
$size = filesize(PATH);
$ip = $_SERVER['REMOTE_ADDR'];
$time = time();
$data = "\n$ip,$time;";

if(flock($f,LOCK_EX)){
    fwrite($f,$data);
    flock($f,LOCK_UN);
}
fclose($f);


$content = file_get_contents(PATH);
$datas = explode(';',$content);


for($i=0;$i<count($datas);$i++){
    $ds = explode(',',$datas[$i]);
    // var_dump($ds);
    if(count($ds) < 2)
        continue;
    $s = time() - intval($ds[1]);
    // echo $s;
    if($s < 60*5){
        $min_five_minutes++;
    }
    $total++;

}


session_start();
//文件保存目录
const PATH2 = 'online.txt';

// 设置时长
$online_time = 60;

if(file_exists(PATH2))
    $file = file(PATH2);
else
    $file = [];

$f2 = fopen(PATH2,'w+');
foreach($file as $line){
    if(substr_count($line,',') < 1)
        continue;
    $id = explode(',',$line)[1];
    $time = explode(',',$line)[2];
    // echo $id,' ',session_id();
    if($id == session_id())
        continue;
    if((time() - intval($time)) < $online_time)
        fwrite($f2,"$line\n");
}


$id = session_id();
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
fwrite($f2,"$ip,$id,$time");

$onlinec = 0;
$onlinecp = file(PATH2);
foreach ($onlinecp as $l){
	if(substr_count($l,',') >=1 )
		$onlinec++;
}

echo "</br>当前在线人数：$onlinec";

echo "</br>五分内访问次数：$min_five_minutes </br>
今天共 $total 人访问</br>";
?>
</p>
    <p>© 2020 <?php $this->options->title() ?></p>

    <div style="margin-top: 30px;">
        Theme Mdxs By <a href="https://blog.jamiexu.cn"
                         style="text-decoration:none;color: black;" target="_blank">Jamiexu </a>
        |
        Powered by <a href="http://www.typecho.org" style="text-decoration:none;color: black;"
                      target="_blank">Typecho</a>
    </div>

</footer>
<!--</div>-->

</div>

</div>

</html>
